# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

set(NATIVE ${PROJECT_SOURCE_DIR}/java/native)
set(NATIVE_FILE ${NATIVE}/com_intel_hpnl_core_EqService.cc ${NATIVE}/com_intel_hpnl_core_Connection.cc ${NATIVE}/com_intel_hpnl_core_CqService.cc ${NATIVE}/com_intel_hpnl_core_Utils.cc ${NATIVE}/com_intel_hpnl_core_RdmService.cc ${NATIVE}/com_intel_hpnl_core_RdmConnection.cc)

if(APPLE)
  set(JNI_INCLUDE "$ENV{JAVA_HOME}/include" "$ENV{JAVA_HOME}/include/darwin")
endif()
if(LINUX)
  set(JNI_INCLUDE "$ENV{JAVA_HOME}/include" "$ENV{JAVA_HOME}/include/linux")
endif()
include_directories(${JNI_INCLUDE})

add_library(hpnl SHARED ${DEMULTIPLEXER_FILE} ${CORE_FILE} ${SERVICE_FILE} ${EXTERNAL_DEMULTIPLEXER_FILE} ${EXTERNAL_SERVICE_FILE} ${NATIVE_FILE} ${CHUNK_FILE})
target_link_libraries(hpnl fabric boost_system)
set_target_properties(hpnl PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

set(CMAKE_INSTALL_PREFIX "/usr/local")
install(TARGETS hpnl LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)

file(GLOB INCLUDE_FILE ${PROJECT_SOURCE_DIR}/include/HPNL/*.h)
install(FILES ${INCLUDE_FILE} DESTINATION include/HPNL)

